Skip to content

loop: reject binding to procfs and sysfs files#910

Open
blktests-ci[bot] wants to merge 1 commit into
linus-master_basefrom
series/1103283=>linus-master
Open

loop: reject binding to procfs and sysfs files#910
blktests-ci[bot] wants to merge 1 commit into
linus-master_basefrom
series/1103283=>linus-master

Conversation

@blktests-ci

@blktests-ci blktests-ci Bot commented May 30, 2026

Copy link
Copy Markdown

Pull request for series with
subject: loop: reject binding to procfs and sysfs files
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1103283

@blktests-ci

blktests-ci Bot commented May 30, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8fde5d1
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci

blktests-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown
Author

Upstream branch: e43ffb6
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 7f7bcc5 to 262663f Compare June 1, 2026 09:15
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from c6dc343 to fc36596 Compare June 3, 2026 13:56
@blktests-ci

blktests-ci Bot commented Jun 3, 2026

Copy link
Copy Markdown
Author

Upstream branch: ba3e43a
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 262663f to fcfe5d2 Compare June 3, 2026 14:11
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from fc36596 to 7bed9c3 Compare June 5, 2026 09:48
@blktests-ci

blktests-ci Bot commented Jun 5, 2026

Copy link
Copy Markdown
Author

Upstream branch: ddd664b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from fcfe5d2 to 69995fa Compare June 5, 2026 09:59
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 7bed9c3 to a7bb5c5 Compare June 7, 2026 14:54
@blktests-ci

blktests-ci Bot commented Jun 7, 2026

Copy link
Copy Markdown
Author

Upstream branch: 979c294
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 69995fa to 571d345 Compare June 7, 2026 15:21
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from a7bb5c5 to 5e41a3b Compare June 10, 2026 13:31
@blktests-ci

blktests-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: acb7500
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 571d345 to 26e348e Compare June 10, 2026 14:05
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 5e41a3b to c3a084b Compare June 10, 2026 20:26
@blktests-ci

blktests-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Author

Upstream branch: 9716c08
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 26e348e to 9f9323e Compare June 11, 2026 09:37
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from c3a084b to 5f78e5d Compare June 12, 2026 22:27
@blktests-ci

blktests-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 2a2974b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 9f9323e to 2f1a4ef Compare June 12, 2026 23:02
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 5f78e5d to e48f9db Compare June 13, 2026 01:19
@blktests-ci

blktests-ci Bot commented Jun 13, 2026

Copy link
Copy Markdown
Author

Upstream branch: 062871f
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from 2f1a4ef to c620e94 Compare June 13, 2026 02:00
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch 2 times, most recently from 199644a to e6d9eb8 Compare June 17, 2026 12:02
@blktests-ci

blktests-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 66affa3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from c620e94 to b432ad6 Compare June 17, 2026 14:32
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from e6d9eb8 to 7d8604f Compare June 24, 2026 01:11
I noticed that /dev/loopX accepts pseudo files, for loop_validate_file()
currently only checks:

  if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
      return -EINVAL;

and pseudo files are treated as S_ISREG().

Reading from pseudo files via /dev/loopX causes unexpected results, as it
tries to repeatedly read the entire content up to the size visible to the
"ls" command (padded with repeating data).

  # ls -l /sys/power/pm_test
  -rw-r--r-- 1 root root 4096 May 26 22:14 /sys/power/pm_test
  # cat /sys/power/pm_test | wc
        1       6      48
  # cat $(losetup -f --show /sys/power/pm_test) | wc
       85     513    4096

Writing to pseudo files via /dev/loopX might also cause undesirable
results. Therefore, explicitly reject binding to pseudo files on procfs
and sysfs for now. Other filesystems can be appended as needed.

There is another intention for this change. Currently, we are evaluating
the possibility of calling drain_workqueue() from __loop_clr_fd() in order
to address a NULL pointer dereference in lo_rw_aio() [1].
However, introducing drain_workqueue() into the loop teardown path where
disk->open_mutex is held forms a circular locking dependency when a pseudo
file that takes a global lock is specified as the backing store for the
loop device.

If drain_workqueue() is called from __loop_clr_fd(), an example of a
circular locking dependency that involves system_transition_mutex and
disk->open_mutex can be triggered by the following reproduction steps:

  # echo 7:0 > /sys/power/resume
  # losetup /dev/loop0 /sys/power/resume
  # cat /dev/loop0 > /dev/null
  # losetup -d /dev/loop0

Even if our final solution for [1] does not call drain_workqueue() with
disk->open_mutex held, rejecting binding to pseudo files that confuse
userspace programs is a standalone improvement.

Link: https://syzkaller.appspot.com/bug?extid=cd8a9a308e879a4e2c28 [1]
Analyzed-by: AI Mode in Google Search (no mail address)
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
@blktests-ci

blktests-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Author

Upstream branch: bade58e
series: https://patchwork.kernel.org/project/linux-block/list/?series=1103283
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1103283=>linus-master branch from b432ad6 to 3370523 Compare June 24, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants